import 'package:cloudapp/pages/base.dart';
import 'package:fijkplayer/fijkplayer.dart';
import 'package:flutter/material.dart';

class VideoPlayerPage extends StatefulWidget {
  static const pageName = "/viewer/video";
  final String url;
  VideoPlayerPage({Key key, @required this.url}): super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _VideoPlayer();
  }
}

class _VideoPlayer extends BaseState<VideoPlayerPage> {
  final FijkPlayer player = FijkPlayer();

  @override
  void initState() {
    super.initState();
    player.setDataSource(widget.url, autoPlay: true);
  }

  @override
  void dispose() {
    super.dispose();
    player.release();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('video Player'),
        elevation: 0,
      ),
      body: Center(
        child: Container(
          alignment: Alignment.center,
          child: FijkView(
            player: player,
          ),
        ),
      ),
    );
  }
}
